import axios,{AxiosInstance} from 'axios';

axios.defaults.baseURL ="http://localhost:9000";
axios.defaults.headers.post["Content-Type"] ="application/json;charset=UTF-8";

axios.interceptors.request.use(
    config=>{ 
        let access_token= sessionStorage.getItem("access_token");// 在发送请求前把sessionStorage中的token写到请求头里
        config.headers={
            Authorization: `Bearer ${access_token}`,
        };
        return config;
    },
    error=>{
        return Promise.reject(error);
    }
);

axios.interceptors.response.use(
    response=>{
        return response.data;
    },
    error=>{
        return Promise.reject(error);
    }
)


export default axios;